﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YJKArchUtils.Utils;
using YJKArchCriterion;
using YJKGeometryFuncs;
using YJKRevitStairs.StairsModel.CommonUnit;
using YJKRevitStairs.StairsModel.DataInfos;
using YJKRevitStairs.StairsModel.Kit;

namespace YJKRevitStairs.StairsModel.Form
{
	public partial class MultiRunStairsForm : EscBaseForm
	{
		public MultiRunStairsForm(ExternalCommandData cmdData)
		{
			this.m_Revit = cmdData;
			this.m_ProjectionDrawingKit = new MultiRunStairsKit(this.m_Revit.Application.Application);
			this.m_ComponentTypeManager = new ComponentTypeManager(this.m_Revit.Application.ActiveUIDocument.Document);
			string archStdXmlPath = FormParamManager.GetArchStdXmlPath();
			this.m_StairArchStd = StairArchStd.GetInstance("08BJ7-1", archStdXmlPath);
			this.m_listAllLevels = new List<Level>(YJKRevitStairs.StairsModel.CommonUnit.Common.GetSortLevels(this.m_Revit.Application.ActiveUIDocument.Document, double.MinValue, double.MaxValue));
			this.m_listStairsData = new List<double>();
			this.InitializeComponent();
			this.m_MainPreviewer = new Previewer(this, this.pnlPreview.Left, this.pnlPreview.Top, this.pnlPreview.Width, this.pnlPreview.Height, 1u);
			this.pnlPreview.Visible = false;
			base.MouseWheel += this.m_MainPreviewer.MouseWheel;
		}

		public double TopOffset
		{
			get
			{
				return YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbTopOffset.Text, 0.0);
			}
			set
			{
				this.hyTbTopOffset.Text = value.ToString("f2");
			}
		}

		public double BottomOffset
		{
			get
			{
				return YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbBottomOffset.Text, 0.0);
			}
			set
			{
				this.hyTbBottomOffset.Text = value.ToString("f2");
			}
		}

		public double StairsWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbStairsWidth.Text);
			}
			set
			{
				this.hyTbStairsWidth.Text = value.ToString("f2");
			}
		}

		public double StairsLength
		{
			get
			{
				return Convert.ToDouble(this.hyTbStairsLength.Text);
			}
			set
			{
				this.hyTbStairsLength.Text = value.ToString("f2");
			}
		}

		public double WellWidth
		{
			get
			{
				double num = Convert.ToDouble(this.hyTbWellWidth.Text);
				if (num == 0.0)
				{
					num = 0.01;
				}
				return num;
			}
			set
			{
				this.hyTbWellWidth.Text = value.ToString("f2");
			}
		}

		public int TreadCount
		{
			get
			{
				return Convert.ToInt32(this.nudTreadCount.Value.ToString());
			}
			set
			{
				this.nudTreadCount.Value = value;
			}
		}

		public int RunNum
		{
			get
			{
				if (this.hycmbRunNum.SelectedIndex == 0)
				{
					return 3;
				}
				return 4;
			}
			set
			{
				if (value == 3)
				{
					this.hycmbRunNum.SelectedIndex = 0;
					this.nud4RunNum.Enabled = false;
					this.lblRun4.Enabled = false;
					this.m_nRiserSubTread = 3;
					return;
				}
				this.hycmbRunNum.SelectedIndex = 1;
				this.nud4RunNum.Enabled = true;
				this.lblRun4.Enabled = true;
				this.m_nRiserSubTread = 4;
			}
		}

		public int Run1TreadCount
		{
			get
			{
				return Convert.ToInt32(this.nud1RunNum.Value.ToString());
			}
			set
			{
				this.nud1RunNum.Value = value;
			}
		}

		public int Run2TreadCount
		{
			get
			{
				return Convert.ToInt32(this.nud2RunNum.Value.ToString());
			}
			set
			{
				this.nud2RunNum.Value = value;
			}
		}

		public int Run3TreadCount
		{
			get
			{
				return Convert.ToInt32(this.nud3RunNum.Value.ToString());
			}
			set
			{
				this.nud3RunNum.Value = value;
			}
		}

		public int Run4TreadCount
		{
			get
			{
				return Convert.ToInt32(this.nud4RunNum.Value.ToString());
			}
			set
			{
				this.nud4RunNum.Value = value;
			}
		}

		public double TreadHeight
		{
			get
			{
				return Convert.ToDouble(this.hyTbTreadHeight.Text);
			}
			set
			{
				this.hyTbTreadHeight.Text = value.ToString("f2");
			}
		}

		public double TreadDepth
		{
			get
			{
				return Convert.ToDouble(this.hyTbTreadDepth.Text);
			}
			set
			{
				this.hyTbTreadDepth.Text = value.ToString("f2");
			}
		}

		public string UsingRange
		{
			get
			{
				return this.comboUsingRange.Text;
			}
		}

		public int RunStructualDepth
		{
			get
			{
				return YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(this.tbRunThickness.Text, 0);
			}
			set
			{
				this.tbRunThickness.Text = value.ToString();
			}
		}

		public int RunRiserThickness
		{
			get
			{
				return YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(this.tbRiserThickness.Text, 0);
			}
			set
			{
				this.tbRiserThickness.Text = value.ToString();
			}
		}

		public int TreadThickness
		{
			get
			{
				return YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(this.tbTreadThickness.Text, 0);
			}
			set
			{
				this.tbTreadThickness.Text = value.ToString();
			}
		}

		public double BeamWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbBeamWidth.Text);
			}
			set
			{
				this.hyTbBeamWidth.Text = value.ToString("f2");
			}
		}

		public double BeamHeight
		{
			get
			{
				return Convert.ToDouble(this.hyTbBeamHeight.Text);
			}
			set
			{
				this.hyTbBeamHeight.Text = value.ToString("f2");
			}
		}

		public double LandingWidth
		{
			get
			{
				return Convert.ToDouble(this.hyTbLandingWidth.Text);
			}
			set
			{
				this.hyTbLandingWidth.Text = value.ToString("f2");
			}
		}

		public int LandingThickness
		{
			get
			{
				return YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(this.tbLandThickness.Text, 0);
			}
			set
			{
				this.tbLandThickness.Text = value.ToString();
			}
		}

		public double RunMaxLength
		{
			get
			{
				return Convert.ToDouble(this.hyTbStairsLength.Text) - Convert.ToDouble(this.hyTbLandingWidth.Text);
			}
		}

		public double RotateAngle
		{
			get
			{
				return YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbRotateAngle.Text, 0.0) / 180.0 * Math.PI;
			}
			set
			{
				this.hyTbRotateAngle.Text = (value * 180.0 / Math.PI).ToString("f0");
			}
		}

		public bool HasTopLanding
		{
			get
			{
				return this.chbTopLanding.Checked;
			}
			set
			{
				this.chbTopLanding.Checked = value;
			}
		}

		public XYZ BasePoint
		{
			get
			{
				return this.m_BasePoint;
			}
		}

		public MultiRunStairsForm.MeasureType theMeasureType
		{
			get
			{
				return this.m_MeasureType;
			}
		}

		public double GetRunWidth()
		{
			return (this.StairsWidth - this.WellWidth) / 2.0;
		}

		public List<LineRunData> GetLstLineRunData()
		{
			List<LineRunData> list = new List<LineRunData>();
			for (int i = 0; i < this.RunNum; i++)
			{
				LineRunData lineRunData = new LineRunData();
				lineRunData.TheStairsType = this.m_ComponentTypeManager.GetStairsType();
				lineRunData.RunWidth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.GetRunWidth());
				lineRunData.TreadHeight = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
				lineRunData.TreadDepth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.TreadDepth);
				switch (i)
				{
				case 0:
					lineRunData.TreadCount = this.Run1TreadCount;
					break;
				case 1:
					lineRunData.TreadCount = this.Run2TreadCount;
					break;
				case 2:
					lineRunData.TreadCount = this.Run3TreadCount;
					break;
				case 3:
					lineRunData.TreadCount = this.Run4TreadCount;
					break;
				}
				lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
				lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
				lineRunData.BottomElevation = 0.0;
				lineRunData.TreadThickness = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet((double)this.TreadThickness);
				lineRunData.RunStructualDepth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet((double)this.RunStructualDepth);
				lineRunData.RiserThickness = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet((double)this.RunRiserThickness);
				list.Add(lineRunData);
			}
			return list;
		}

		public List<BaseSupportData> GetSupportData()
		{
			List<BaseSupportData> list = new List<BaseSupportData>();
			if (this.chkOutSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_OutSide
				});
			}
			if (this.chkMiddleSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_Mid,
					nSurportNum = 3
				});
			}
			if (this.chkInsideSupport.Checked)
			{
				list.Add(new BaseSupportData
				{
					SupportType = this.m_ComponentTypeManager.GetSupportType(this.cmbSupport.SelectedIndex),
					Style = SupportStyle.ST_Inside
				});
			}
			return list;
		}

		public BaseLandingData GetLandingData()
		{
			BaseLandingData baseLandingData = new BaseLandingData();
			if (this.rdbRactangle.Checked)
			{
				baseLandingData.TheType = LandingType.LT_Rect;
			}
			else
			{
				baseLandingData.TheType = LandingType.LT_Sector;
			}
			baseLandingData.Width = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.LandingWidth);
			baseLandingData.BottomElevation = 0.0;
			baseLandingData.LandingThickness = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet((double)this.LandingThickness);
			return baseLandingData;
		}

		public BaseBeamData GetBeamData()
		{
			return new BaseBeamData
			{
				BeamHeight = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.BeamHeight),
				BeamWidth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.BeamWidth)
			};
		}

		public YJKRevitStairs.StairsModel.DataInfos.FloorType GetFloorType()
		{
			if (this.rbFirstFloor.Checked)
			{
				return YJKRevitStairs.StairsModel.DataInfos.FloorType.FT_Bottom;
			}
			if (this.rbMiddleFloor.Checked)
			{
				return YJKRevitStairs.StairsModel.DataInfos.FloorType.FT_Mid;
			}
			return YJKRevitStairs.StairsModel.DataInfos.FloorType.FT_Top;
		}

		public bool GetNoteInfo()
		{
			return this.chkNoteInfo.Checked;
		}

		public bool GetLeftSideUp()
		{
			return this.rbLeftUp.Checked;
		}

		public bool GetTBMirror()
		{
			return this.chkTBMirror.Checked;
		}

		public bool GetLRMirror()
		{
			return this.chkLRMirror.Checked;
		}

		public int GetInsertPointIndex()
		{
			return this.m_BasePointIndex;
		}

		public bool GetBottomBeam()
		{
			return this.chkBottomBeam.Checked;
		}

		public bool GetMiddleBeam()
		{
			return this.chkMidBeam.Checked;
		}

		public bool GetTopBeam()
		{
			return this.chkTopBeam.Checked;
		}

		public bool GetOuterRail()
		{
			return this.chkOutRailing.Checked;
		}

		public bool GetInnerRail()
		{
			return this.chkInnerRailing.Checked;
		}

		public double GetTreadThickness()
		{
			return this.m_dTreadThickness;
		}

		public double GetBottomElevation()
		{
			return this.m_BottomLevel.Elevation;
		}

		public double GetLevelValue()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.m_dLevelValue);
		}

		public double GetTopOffset()
		{
			return this.TopOffset;
		}

		public RailingType GetInnerRailType()
		{
			return this.m_ComponentTypeManager.GetRailingType(this.cmbInnerRailingType.SelectedIndex);
		}

		public double GetInnerRailHeight()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(Convert.ToDouble(this.m_ComponentTypeManager.GetHeightsOfRailingTypeList()[this.cmbInnerRailingType.SelectedIndex]));
		}

		public RailingType GetOuterRailType()
		{
			return this.m_ComponentTypeManager.GetRailingType(this.cmbOutRailingType.SelectedIndex);
		}

		public double GetOuterRailHeight()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(Convert.ToDouble(this.m_ComponentTypeManager.GetHeightsOfRailingTypeList()[this.cmbOutRailingType.SelectedIndex]));
		}

		protected override void DefWndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg == 1125)
			{
				if (m.WParam.ToInt32() != 1)
				{
					return;
				}
				List<CurveInfo> curves = new List<CurveInfo>();
				List<TextNoteInfo> textNotes = new List<TextNoteInfo>();
				try
				{
					this.GetProfileCurves(ref curves, ref textNotes);
					this.m_MainPreviewer.Curves = curves;
					this.m_MainPreviewer.TextNotes = textNotes;
					return;
				}
				catch (Exception)
				{
					return;
				}
			}
			base.DefWndProc(ref m);
		}

		private void GetProfileCurves(ref List<CurveInfo> curvesInfoList, ref List<TextNoteInfo> textNoteInfoList)
		{
			MultiRunStairs multiRunStairs = new MultiRunStairs();
			multiRunStairs.m_dStairsWidth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsWidth);
			multiRunStairs.m_dStairsLength = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsLength);
			multiRunStairs.m_dWellWidth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.WellWidth);
			multiRunStairs.m_lstRunData = this.GetLstLineRunData();
			multiRunStairs.m_nRunNum = this.RunNum;
			multiRunStairs.m_bHasTopLanding = this.HasTopLanding;
			multiRunStairs.m_LandData = this.GetLandingData();
			multiRunStairs.m_BeamData = this.GetBeamData();
			this.m_ProjectionDrawingKit.MultiRunStairsProfileCurves(ref multiRunStairs, this.chkNoteInfo.Checked, this.m_BasePointIndex, this.chkLRMirror.Checked, this.chkTBMirror.Checked, this.rbLeftUp.Checked, this.RotateAngle, this.chkBottomBeam.Checked, this.chkMidBeam.Checked, this.chkTopBeam.Checked);
			foreach (SingleRunCurveInfo singleRunCurveInfo in multiRunStairs.m_listRunCurve)
			{
				curvesInfoList.AddRange(singleRunCurveInfo.RunBoundaryCurvesInfoList);
				curvesInfoList.AddRange(singleRunCurveInfo.RunRiserCurvesInfoList);
				curvesInfoList.AddRange(singleRunCurveInfo.RunPathCurvesInfoList);
			}
			foreach (LandingCurveInfo landingCurveInfo in multiRunStairs.m_listLandCurve)
			{
				curvesInfoList.AddRange(landingCurveInfo.m_arCurveInfo);
			}
			curvesInfoList.AddRange(multiRunStairs.m_listOtherCurve);
			textNoteInfoList = multiRunStairs.m_listText;
		}

		private void ReadData()
		{
			string path = Product.UserDataLocation + "\\MultiRunStairsForm.dat";
			if (!File.Exists(path))
			{
				this.m_Calculating = true;
				this.comboUsingRange.Text = "商场";
				this.hyTbBottomOffset.Text = "0.00";
				this.hyTbTopOffset.Text = "0.00";
				this.hyTbStairsWidth.Text = "2900.00";
				this.hyTbStairsLength.Text = "3800.00";
				this.hyTbWellWidth.Text = "100.00";
				this.nudTreadCount.Value = 30m;
				this.hycmbRunNum.Text = "3";
				this.nud1RunNum.Value = 10m;
				this.nud2RunNum.Value = 10m;
				this.nud3RunNum.Value = 10m;
				this.nud4RunNum.Value = 10m;
				this.nud4RunNum.Enabled = false;
				this.hyTbTreadHeight.Text = "150.00";
				this.hyTbTreadDepth.Text = "280.00";
				this.tbRunThickness.Text = "120";
				this.tbLandThickness.Text = "120";
				this.tbRiserThickness.Text = "30";
				this.tbTreadThickness.Text = "30";
				this.chkInnerRailing.Checked = true;
				this.chkOutRailing.Checked = true;
				this.chkOutSupport.Checked = true;
				this.chkMiddleSupport.Checked = true;
				this.chkInsideSupport.Checked = true;
				this.chkBottomBeam.Checked = true;
				this.chkMidBeam.Checked = true;
				this.chkTopBeam.Checked = true;
				this.hyTbBeamWidth.Text = "200.00";
				this.hyTbBeamHeight.Text = "400.00";
				this.rbLeftUp.Checked = true;
				this.rbRightUp.Checked = false;
				this.rbFirstFloor.Checked = true;
				this.rbMiddleFloor.Checked = false;
				this.rbTopFloor.Checked = false;
				this.rdbRactangle.Checked = true;
				this.rdbArc.Checked = false;
				this.chbTopLanding.Checked = false;
				this.hyTbLandingWidth.Text = "1400";
				this.hyTbRotateAngle.Text = "0.00";
				this.chkTBMirror.Checked = false;
				this.chkLRMirror.Checked = false;
				this.chkNoteInfo.Checked = true;
				this.m_Calculating = false;
				return;
			}
			this.m_Calculating = true;
			FileStream fileStream = new FileStream(path, FileMode.Open);
			StreamReader streamReader = new StreamReader(fileStream);
			streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
			int index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.comboUsingRange, index);
			this.hyTbBottomOffset.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			this.hyTbTopOffset.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			this.hyTbStairsWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbStairsLength.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbWellWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbTreadHeight.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbTreadDepth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.nudTreadCount.Value = Convert.ToInt32(streamReader.ReadLine());
			this.hycmbRunNum.Text = streamReader.ReadLine();
			this.nud1RunNum.Value = Convert.ToInt32(streamReader.ReadLine());
			this.nud2RunNum.Value = Convert.ToInt32(streamReader.ReadLine());
			this.nud3RunNum.Value = Convert.ToInt32(streamReader.ReadLine());
			if (this.hycmbRunNum.Text == "4")
			{
				this.nud4RunNum.Value = Convert.ToInt32(streamReader.ReadLine());
				this.nud4RunNum.Enabled = true;
			}
			else
			{
				this.nud4RunNum.Enabled = false;
			}
			this.tbRunThickness.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 120).ToString();
			this.tbLandThickness.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 120).ToString();
			this.tbRiserThickness.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 30).ToString();
			this.tbTreadThickness.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 30).ToString();
			this.chkInnerRailing.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkOutRailing.Checked = Convert.ToBoolean(streamReader.ReadLine());
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbInnerRailingType, index);
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbOutRailingType, index);
			this.chkOutSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkMiddleSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkInsideSupport.Checked = Convert.ToBoolean(streamReader.ReadLine());
			index = Convert.ToInt32(streamReader.ReadLine());
			this.SetComboBoxSelectedIndex(this.cmbSupport, index);
			this.chkBottomBeam.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkMidBeam.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkTopBeam.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.hyTbBeamWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			this.hyTbBeamHeight.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f2");
			if (Convert.ToInt32(streamReader.ReadLine()) == 0)
			{
				this.rbLeftUp.Checked = true;
				this.rbRightUp.Checked = false;
			}
			else
			{
				this.rbLeftUp.Checked = false;
				this.rbRightUp.Checked = true;
			}
			int num = Convert.ToInt32(streamReader.ReadLine());
			if (num == 0)
			{
				this.rbFirstFloor.Checked = true;
				this.rbMiddleFloor.Checked = false;
				this.rbTopFloor.Checked = false;
			}
			else if (1 == num)
			{
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = true;
				this.rbTopFloor.Checked = false;
			}
			else
			{
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = false;
				this.rbTopFloor.Checked = true;
			}
			this.hyTbRotateAngle.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(streamReader.ReadLine(), 0.0).ToString("f2");
			int num2 = Convert.ToInt32(streamReader.ReadLine());
			if (num2 == 0)
			{
				this.rdbRactangle.Checked = true;
				this.rdbArc.Checked = false;
			}
			else if (1 == num2)
			{
				this.rdbRactangle.Checked = false;
				this.rdbArc.Checked = true;
			}
			this.hyTbLandingWidth.Text = Convert.ToDouble(streamReader.ReadLine()).ToString("f0");
			this.chbTopLanding.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chbTopLanding.Checked = false;
			this.m_BasePointIndex = Convert.ToInt32(streamReader.ReadLine());
			this.chkTBMirror.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkLRMirror.Checked = Convert.ToBoolean(streamReader.ReadLine());
			this.chkNoteInfo.Checked = Convert.ToBoolean(streamReader.ReadLine());
			streamReader.Close();
			fileStream.Close();
			this.m_Calculating = false;
		}

		public void SaveData()
		{
			FileStream fileStream = new FileStream(Product.UserDataLocation + "\\MultiRunStairsForm.dat", FileMode.Create);
			StreamWriter streamWriter = new StreamWriter(fileStream);
			streamWriter.WriteLine(this.comboUsingRange.SelectedIndex);
			streamWriter.WriteLine(this.hyTbBottomOffset.Text);
			streamWriter.WriteLine(this.hyTbTopOffset.Text);
			streamWriter.WriteLine(this.hyTbStairsWidth.Text);
			streamWriter.WriteLine(this.hyTbStairsLength.Text);
			streamWriter.WriteLine(this.hyTbWellWidth.Text);
			streamWriter.WriteLine(this.hyTbTreadHeight.Text);
			streamWriter.WriteLine(this.hyTbTreadDepth.Text);
			streamWriter.WriteLine(this.nudTreadCount.Value.ToString());
			streamWriter.WriteLine(this.RunNum.ToString());
			streamWriter.WriteLine(this.nud1RunNum.Value.ToString());
			streamWriter.WriteLine(this.nud2RunNum.Value.ToString());
			streamWriter.WriteLine(this.nud3RunNum.Value.ToString());
			if (this.RunNum == 4)
			{
				streamWriter.WriteLine(this.nud4RunNum.Value.ToString());
			}
			streamWriter.WriteLine(this.tbRunThickness.Text);
			streamWriter.WriteLine(this.tbLandThickness.Text);
			streamWriter.WriteLine(this.tbRiserThickness.Text);
			streamWriter.WriteLine(this.tbTreadThickness.Text);
			streamWriter.WriteLine(this.chkInnerRailing.Checked);
			streamWriter.WriteLine(this.chkOutRailing.Checked);
			streamWriter.WriteLine(this.cmbInnerRailingType.SelectedIndex);
			streamWriter.WriteLine(this.cmbOutRailingType.SelectedIndex);
			streamWriter.WriteLine(this.chkOutSupport.Checked);
			streamWriter.WriteLine(this.chkMiddleSupport.Checked);
			streamWriter.WriteLine(this.chkInsideSupport.Checked);
			streamWriter.WriteLine(this.cmbSupport.SelectedIndex);
			streamWriter.WriteLine(this.chkBottomBeam.Checked);
			streamWriter.WriteLine(this.chkMidBeam.Checked);
			streamWriter.WriteLine(this.chkTopBeam.Checked);
			streamWriter.WriteLine(this.hyTbBeamWidth.Text);
			streamWriter.WriteLine(this.hyTbBeamHeight.Text);
			if (this.rbLeftUp.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else
			{
				streamWriter.WriteLine(1);
			}
			if (this.rbFirstFloor.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else if (this.rbMiddleFloor.Checked)
			{
				streamWriter.WriteLine(1);
			}
			else
			{
				streamWriter.WriteLine(2);
			}
			streamWriter.WriteLine(this.hyTbRotateAngle.Text);
			if (this.rdbRactangle.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else if (this.rdbArc.Checked)
			{
				streamWriter.WriteLine(1);
			}
			streamWriter.WriteLine(this.hyTbLandingWidth.Text);
			streamWriter.WriteLine(this.chbTopLanding.Checked);
			streamWriter.WriteLine(this.m_BasePointIndex);
			streamWriter.WriteLine(this.chkTBMirror.Checked);
			streamWriter.WriteLine(this.chkLRMirror.Checked);
			streamWriter.WriteLine(this.chkNoteInfo.Checked);
			streamWriter.Flush();
			streamWriter.Close();
			fileStream.Close();
		}

		private void MultiRunStairsForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.InitializeComboBox(this.comboUsingRange, this.m_ComponentTypeManager.GetUsingRangeList());
			this.InitializeComboBox(this.cmbInnerRailingType, this.m_ComponentTypeManager.GetRailingTypeNameList());
			this.InitializeComboBox(this.cmbOutRailingType, this.m_ComponentTypeManager.GetRailingTypeNameList());
			this.InitializeComboBox(this.cmbSupport, this.m_ComponentTypeManager.GetSupportTypeNameList());
			List<string> list = new List<string>();
			foreach (Element element in this.m_listAllLevels)
			{
				if (!list.Contains(element.Name))
				{
					list.Add(element.Name);
				}
			}
			this.InitializeComboBox(this.cmbTopLevel, list);
			this.InitializeComboBox(this.cmbBottomLevel, list);
			this.hycmbRunNum.Items.Clear();
			this.hycmbRunNum.Items.Add(3);
			this.hycmbRunNum.Items.Add(4);
			this.ReadData();
			this.UpdateRailingData();
			this.UpdateSupportData();
			this.UpdateBeamData();
			this.UpdateStairsData();
			this.m_BottomLevel = this.m_Revit.Application.ActiveUIDocument.ActiveView.GenLevel;
			for (int i = 0; i < this.m_listAllLevels.Count; i++)
			{
				if (this.m_BottomLevel.Id == this.m_listAllLevels.ElementAt(i).Id)
				{
					if (this.m_listAllLevels.Count - 1 == i)
					{
						this.m_TopLevel = this.m_BottomLevel;
						this.cmbTopLevel.SelectedIndex = i;
						this.m_dLevelValue = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_BottomLevel.Elevation - this.m_listAllLevels.ElementAt(i - 1).Elevation);
						this.TopOffset = this.m_dLevelValue;
					}
					else
					{
						this.m_TopLevel = this.m_listAllLevels.ElementAt(i + 1);
						this.cmbTopLevel.SelectedIndex = i + 1;
						this.m_dLevelValue = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
						this.TopOffset = 0.0;
					}
					this.cmbBottomLevel.SelectedIndex = i;
					break;
				}
			}
			this.BottomOffset = 0.0;
			this.m_bInitialize = false;
		}

		private void MultiRunStairsForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (DialogResult.Cancel == base.DialogResult)
			{
				return;
			}
			string text = "";
			if (!this.ValidatingParameters(ref text))
			{
				MessageBox.Show(text, "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
			}
			this.SaveData();
		}

		private void InitializeComboBox(System.Windows.Forms.ComboBox control, List<string> typeNameList)
		{
			control.Items.Clear();
			foreach (string item in typeNameList)
			{
				control.Items.Add(item);
			}
			if (control.Items.Count > 0)
			{
				control.SelectedIndex = 0;
			}
		}

		private void SetComboBoxSelectedIndex(System.Windows.Forms.ComboBox control, int index)
		{
			if (index < 0 || index >= control.Items.Count)
			{
				return;
			}
			control.SelectedIndex = index;
		}

		private bool ValidatingParameters(ref string message)
		{
			if (this.chkInnerRailing.Checked || this.chkOutRailing.Checked)
			{
				if (this.cmbInnerRailingType.Items.Count == 0)
				{
					message = "栏杆类型为空";
					return false;
				}
				if (this.cmbOutRailingType.Items.Count == 0)
				{
					message = "栏杆类型为空";
					return false;
				}
			}
			if ((this.chkOutSupport.Checked || this.chkMiddleSupport.Checked || this.chkInsideSupport.Checked) && this.cmbSupport.Items.Count == 0)
			{
				message = "支持类型为空";
				return false;
			}
			return true;
		}

		private bool ValidatingDataParam(ref string message)
		{
			List<ValidatingData> list = new List<ValidatingData>();
			ValidatingData item = default(ValidatingData);
			double num = (this.StairsWidth - this.WellWidth) / 2.0;
			item.Type = DataType.DT_RunWidth;
			item.Name = "梯段宽度";
			item.Value = num;
			list.Add(item);
			item.Type = DataType.DT_TreadHeight;
			item.Name = "踏步高度";
			item.Value = this.TreadHeight;
			list.Add(item);
			item.Type = DataType.DT_TreadDepth;
			item.Name = "踏步宽度";
			item.Value = this.TreadDepth;
			list.Add(item);
			item.Type = DataType.DT_TreadCount;
			item.Name = "梯段1步数";
			item.Count = this.Run1TreadCount;
			list.Add(item);
			item.Type = DataType.DT_TreadCount;
			item.Name = "梯段2步数";
			item.Count = this.Run2TreadCount;
			list.Add(item);
			item.Type = DataType.DT_TreadCount;
			item.Name = "梯段3步数";
			item.Count = this.Run3TreadCount;
			list.Add(item);
			if (this.RunNum == 4)
			{
				item.Type = DataType.DT_TreadCount;
				item.Name = "梯段4步数";
				item.Count = this.Run4TreadCount;
				list.Add(item);
			}
			item.Type = DataType.DT_LandWidth;
			item.Name = "最小平台宽度";
			item.Value = this.LandingWidth;
			list.Add(item);
			message = FormParamManager.GetValidatingData(list, this.UsingRange, num);
			return message == null;
		}

		private bool MaxTreadCount(ref int maxCount)
		{
			maxCount = ((this.Run1TreadCount > this.Run2TreadCount) ? this.Run1TreadCount : this.Run2TreadCount);
			if (this.RunNum == 3)
			{
				if (maxCount < this.Run3TreadCount)
				{
					maxCount = this.Run3TreadCount;
					return true;
				}
			}
			else
			{
				maxCount = ((maxCount > this.Run3TreadCount) ? maxCount : this.Run3TreadCount);
			}
			if (this.RunNum == 4 && maxCount < this.Run4TreadCount)
			{
				maxCount = this.Run4TreadCount;
				return true;
			}
			return false;
		}

		private void ParametersCalculate(MultiRunStairsForm.ParametersChangeType changeType)
		{
			if (this.m_Calculating)
			{
				return;
			}
			this.m_Calculating = true;
			try
			{
				double stairsHeight = FormParamManager.GetStairsHeight(this.m_dLevelValue, this.TopOffset, this.BottomOffset);
				int nTreadCount = FormParamManager.GetStairsTreadCount(stairsHeight, this.TreadHeight) - this.m_nRiserSubTread;
				switch (changeType)
				{
				case MultiRunStairsForm.ParametersChangeType.PCT_TreadHeight:
					this.TreadHeightChanged(nTreadCount);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_RunNum:
					this.TreadAllCountChanged(this.TreadCount);
					this.TreadHeight = stairsHeight / (double)(this.TreadCount + this.m_nRiserSubTread);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_TreadCount:
					this.TreadAllCountChanged(this.TreadCount);
					this.TreadHeight = stairsHeight / (double)(this.TreadCount + this.m_nRiserSubTread);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run1TreadCount:
					this.Run2TreadCount = this.TreadCount - this.Run1TreadCount - this.Run3TreadCount;
					if (this.RunNum == 4)
					{
						this.Run2TreadCount -= this.Run4TreadCount;
					}
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run2TreadCount:
					this.Run3TreadCount = this.TreadCount - this.Run1TreadCount - this.Run3TreadCount;
					if (this.RunNum == 4)
					{
						this.Run3TreadCount -= this.Run4TreadCount;
					}
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run3TreadCount:
					if (this.RunNum == 4)
					{
						this.Run4TreadCount = this.TreadCount - this.Run1TreadCount - this.Run2TreadCount - this.Run3TreadCount;
					}
					else
					{
						this.Run1TreadCount = this.TreadCount - this.Run2TreadCount - this.Run3TreadCount;
					}
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run4TreadCount:
					this.Run1TreadCount = this.TreadCount - this.Run1TreadCount - this.Run2TreadCount - this.Run3TreadCount;
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_TreadCountAdd:
					if (this.m_nMaxTread * this.RunNum < this.TreadCount)
					{
						int num = this.TreadCount;
						this.TreadCount = num - 1;
					}
					this.TreadAllCountChanged(this.TreadCount);
					this.TreadHeight = stairsHeight / (double)(this.TreadCount + this.m_nRiserSubTread);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run1TreadCountAdd:
					this.Run1TreadCountChanged(true);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run2TreadCountAdd:
					this.Run2TreadCountChanged(true);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run3TreadCountAdd:
					this.Run3TreadCountChanged(true);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run4TreadCountAdd:
					this.Run4TreadCountChanged(true);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_TreadCountSub:
					if (this.m_nMinTread * this.RunNum > this.TreadCount)
					{
						int num = this.TreadCount;
						this.TreadCount = num + 1;
					}
					this.TreadAllCountChanged(this.TreadCount);
					this.TreadHeight = stairsHeight / (double)(this.TreadCount + this.m_nRiserSubTread);
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run1TreadCountSub:
					if (this.m_nMinTread > this.Run1TreadCount)
					{
						int num = this.Run1TreadCount;
						this.Run1TreadCount = num + 1;
					}
					else
					{
						this.Run1TreadCountChanged(false);
					}
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run2TreadCountSub:
					if (this.m_nMinTread > this.Run2TreadCount)
					{
						int num = this.Run2TreadCount;
						this.Run2TreadCount = num + 1;
					}
					else
					{
						this.Run2TreadCountChanged(false);
					}
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run3TreadCountSub:
					if (this.m_nMinTread > this.Run3TreadCount)
					{
						int num = this.Run3TreadCount;
						this.Run3TreadCount = num + 1;
					}
					else
					{
						this.Run3TreadCountChanged(false);
					}
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_Run4TreadCountSub:
					if (this.m_nMinTread > this.Run4TreadCount)
					{
						int num = this.Run4TreadCount;
						this.Run4TreadCount = num + 1;
					}
					else
					{
						this.Run4TreadCountChanged(false);
					}
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_StairsLength:
					if (!YJKGeometryFuncs.Geometry.Lessthan_Or_Equal(this.StairsLength, 2.0 * this.LandingWidth))
					{
						int num2 = 0;
						if (this.MaxTreadCount(ref num2) && !this.chbTopLanding.Checked)
						{
							if (this.chbTopLanding.Checked)
							{
								this.TreadDepth = (this.StairsLength - this.LandingWidth) / (double)num2;
							}
						}
						else
						{
							this.TreadDepth = (this.StairsLength - 2.0 * this.LandingWidth) / (double)num2;
						}
					}
					break;
				case MultiRunStairsForm.ParametersChangeType.PCT_LandingWidth:
				{
					int num2 = 0;
					if (this.MaxTreadCount(ref num2) && !this.chbTopLanding.Checked)
					{
						this.StairsLength = this.TreadDepth * (double)num2 + this.LandingWidth;
					}
					else
					{
						this.StairsLength = this.TreadDepth * (double)num2 + 2.0 * this.LandingWidth;
					}
					break;
				}
				case MultiRunStairsForm.ParametersChangeType.PCT_TreadDepth:
				{
					int num2 = 0;
					if (this.MaxTreadCount(ref num2) && !this.chbTopLanding.Checked)
					{
						this.StairsLength = this.TreadDepth * (double)num2 + this.LandingWidth;
					}
					else
					{
						this.StairsLength = this.TreadDepth * (double)num2 + 2.0 * this.LandingWidth;
					}
					break;
				}
				}
				this.m_Calculating = false;
			}
			catch (Exception)
			{
				this.m_Calculating = false;
			}
		}

		private MultiRunStairsForm.ValveChangeType isAddNumericUpDown(NumericUpDown ctrl)
		{
			int num = Convert.ToInt32(ctrl.Text);
			int num2 = Convert.ToInt32(ctrl.Value.ToString());
			if (num2 == num)
			{
				return MultiRunStairsForm.ValveChangeType.VCT_None;
			}
			if (num2 == num + 1)
			{
				return MultiRunStairsForm.ValveChangeType.VCT_AddOne;
			}
			if (num2 + 1 == num)
			{
				return MultiRunStairsForm.ValveChangeType.VCT_SubtractOne;
			}
			return MultiRunStairsForm.ValveChangeType.VCT_ValveChanged;
		}

		private void TreadHeightChanged(int nTreadCount)
		{
			this.TreadAllCountChanged(nTreadCount);
			if (this.RunNum == 3)
			{
				this.TreadCount = this.Run1TreadCount + this.Run2TreadCount + this.Run3TreadCount;
				return;
			}
			this.TreadCount = this.Run1TreadCount + this.Run2TreadCount + this.Run3TreadCount + this.Run4TreadCount;
		}

		private void TreadAllCountChanged(int nTreadCount)
		{
			int num = nTreadCount % this.RunNum;
			int num2 = nTreadCount / this.RunNum;
			if (num == 0)
			{
				this.Run1TreadCount = num2;
				this.Run2TreadCount = num2;
				this.Run3TreadCount = num2;
				this.Run4TreadCount = num2;
			}
			else if (num == 1)
			{
				this.Run1TreadCount = num2 + 1;
				this.Run2TreadCount = num2;
				this.Run3TreadCount = num2;
				this.Run4TreadCount = num2;
			}
			else if (num == 2)
			{
				this.Run1TreadCount = num2 + 1;
				this.Run2TreadCount = num2 + 1;
				this.Run3TreadCount = num2;
				this.Run4TreadCount = num2;
			}
			else if (num == 3)
			{
				this.Run1TreadCount = num2 + 1;
				this.Run2TreadCount = num2 + 1;
				this.Run3TreadCount = num2 + 1;
				this.Run4TreadCount = num2;
			}
			int num3 = 0;
			bool flag = this.MaxTreadCount(ref num3);
			if (!this.m_bInitialize)
			{
				if (!flag || this.chbTopLanding.Checked)
				{
					this.TreadDepth = (this.StairsLength - 2.0 * this.LandingWidth) / (double)num3;
					return;
				}
				if (this.chbTopLanding.Checked)
				{
					this.TreadDepth = (this.StairsLength - this.LandingWidth) / (double)num3;
					return;
				}
			}
			else
			{
				this.TreadDepth = 280.0;
				if (flag && !this.chbTopLanding.Checked)
				{
					this.StairsLength = this.TreadDepth * (double)num3 + this.LandingWidth;
					return;
				}
				this.StairsLength = this.TreadDepth * (double)num3 + 2.0 * this.LandingWidth;
			}
		}

		private void Run1TreadCountChanged(bool isAdd)
		{
			if (this.Run2TreadCount == this.m_nMinTread && isAdd)
			{
				int num = this.Run1TreadCount;
				this.Run1TreadCount = num - 1;
				return;
			}
			if (this.Run2TreadCount == this.m_nMaxTread && !isAdd)
			{
				int num = this.Run1TreadCount;
				this.Run1TreadCount = num + 1;
				return;
			}
			if (isAdd)
			{
				int num = this.Run2TreadCount;
				this.Run2TreadCount = num - 1;
			}
			else
			{
				int num = this.Run2TreadCount;
				this.Run2TreadCount = num + 1;
			}
			this.m_Calculating = false;
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_StairsLength);
		}

		private void Run2TreadCountChanged(bool isAdd)
		{
			if (this.Run3TreadCount == this.m_nMinTread && isAdd)
			{
				int num = this.Run2TreadCount;
				this.Run2TreadCount = num - 1;
				return;
			}
			if (this.Run3TreadCount == this.m_nMaxTread && !isAdd)
			{
				int num = this.Run2TreadCount;
				this.Run2TreadCount = num + 1;
				return;
			}
			if (isAdd)
			{
				int num = this.Run3TreadCount;
				this.Run3TreadCount = num - 1;
			}
			else
			{
				int num = this.Run3TreadCount;
				this.Run3TreadCount = num + 1;
			}
			this.m_Calculating = false;
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_StairsLength);
		}

		private void Run3TreadCountChanged(bool isAdd)
		{
			if (this.RunNum == 4)
			{
				if (this.Run4TreadCount == this.m_nMinTread && isAdd)
				{
					int num = this.Run3TreadCount;
					this.Run3TreadCount = num - 1;
					return;
				}
				if (this.Run4TreadCount == this.m_nMaxTread && !isAdd)
				{
					int num = this.Run3TreadCount;
					this.Run3TreadCount = num + 1;
					return;
				}
				if (isAdd)
				{
					int num = this.Run4TreadCount;
					this.Run4TreadCount = num - 1;
				}
				else
				{
					int num = this.Run4TreadCount;
					this.Run4TreadCount = num + 1;
				}
			}
			else
			{
				if (this.Run1TreadCount == this.m_nMinTread && isAdd)
				{
					int num = this.Run3TreadCount;
					this.Run3TreadCount = num - 1;
					return;
				}
				if (this.Run1TreadCount == this.m_nMaxTread && !isAdd)
				{
					int num = this.Run3TreadCount;
					this.Run3TreadCount = num + 1;
					return;
				}
				if (isAdd)
				{
					int num = this.Run1TreadCount;
					this.Run1TreadCount = num - 1;
				}
				else
				{
					int num = this.Run1TreadCount;
					this.Run1TreadCount = num + 1;
				}
			}
			this.m_Calculating = false;
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_StairsLength);
		}

		private void Run4TreadCountChanged(bool isAdd)
		{
			if (this.Run1TreadCount == this.m_nMinTread && isAdd)
			{
				int num = this.Run4TreadCount;
				this.Run4TreadCount = num - 1;
				return;
			}
			if (this.Run1TreadCount == this.m_nMaxTread && !isAdd)
			{
				int num = this.Run4TreadCount;
				this.Run4TreadCount = num + 1;
				return;
			}
			if (isAdd)
			{
				int num = this.Run1TreadCount;
				this.Run1TreadCount = num - 1;
			}
			else
			{
				int num = this.Run1TreadCount;
				this.Run1TreadCount = num + 1;
			}
			this.m_Calculating = false;
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_StairsLength);
		}

		private void UpdateRailingData()
		{
			if (!this.chkInnerRailing.Checked)
			{
				this.cmbInnerRailingType.Enabled = false;
			}
			else
			{
				this.cmbInnerRailingType.Enabled = true;
			}
			if (!this.chkOutRailing.Checked)
			{
				this.cmbOutRailingType.Enabled = false;
				return;
			}
			this.cmbOutRailingType.Enabled = true;
		}

		private void UpdateSupportData()
		{
			if (!this.chkOutSupport.Checked && !this.chkInsideSupport.Checked)
			{
				this.cmbSupport.Enabled = false;
				return;
			}
			this.cmbSupport.Enabled = true;
		}

		private void UpdateBeamData()
		{
			if (!this.chkBottomBeam.Checked && !this.chkMidBeam.Checked && !this.chkTopBeam.Checked)
			{
				this.hyTbBeamWidth.Enabled = false;
				this.hyTbBeamHeight.Enabled = false;
				return;
			}
			this.hyTbBeamWidth.Enabled = true;
			this.hyTbBeamHeight.Enabled = true;
		}

		private void UpdateStairsData()
		{
			this.m_listStairsData.Clear();
			this.m_listStairsData.Add(this.StairsWidth);
			this.m_listStairsData.Add(this.StairsLength);
			this.m_listStairsData.Add(this.TreadHeight);
			this.m_listStairsData.Add(this.TreadDepth);
			this.m_listStairsData.Add(this.BeamWidth);
			this.m_listStairsData.Add(this.BeamHeight);
			this.m_listStairsData.Add(this.RotateAngle);
			this.m_listStairsData.Add(this.WellWidth);
			this.m_listStairsData.Add(this.LandingWidth);
		}

		private void chkInnerRailing_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateRailingData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkOutRailing_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateRailingData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkOutSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkMiddleSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkInsideSupport_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateSupportData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkBottomBeam_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateBeamData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkMidBeam_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateBeamData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkTopBeam_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateBeamData();
			this.m_MainPreviewer.Refresh();
		}

		private void chkTBMirror_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkLRMirror_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkNoteInfo_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbLeftUp_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbRightUp_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rdbRactangle_CheckedChanged(object sender, EventArgs e)
		{
			this.m_BasePointIndex = 0;
			this.m_MainPreviewer.Refresh();
		}

		private void rdbArc_CheckedChanged(object sender, EventArgs e)
		{
			this.m_BasePointIndex = 0;
			this.m_MainPreviewer.Refresh();
		}

		private void chbTopLanding_CheckedChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_LandingWidth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTopOffset_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBottomOffset_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbStairsWidth_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_StairsWidth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbStairsLength_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_StairsLength);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbWellWidth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTreadHeight_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTreadDepth_TextChanged(object sender, EventArgs e)
		{
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_TreadDepth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbRotateAngle_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBeamWidth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbBeamHeight_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbLandingWidth_TextChanged(object sender, EventArgs e)
		{
			if (ValueValidatingKit.IsInvalidLandingWidthRange(YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbLandingWidth.Text, 0.0)))
			{
				this.hyTbLandingWidth.Text = (this.hyTbLandingWidth.Tag as string);
			}
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_LandingWidth);
			this.m_MainPreviewer.Refresh();
			this.hyTbLandingWidth.Tag = this.hyTbLandingWidth.Text;
		}

		private void cmbTopLevel_TextChanged(object sender, EventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
		}

		private void cmbBottomLevel_TextChanged(object sender, EventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
		}

		private void cmbTopLevel_SelectedIndexChanged(object sender, EventArgs e)
		{
			int selectedIndex = this.cmbTopLevel.SelectedIndex;
			int selectedIndex2 = this.cmbBottomLevel.SelectedIndex;
			this.m_TopLevel = this.m_listAllLevels.ElementAt(selectedIndex);
			this.hyTbTopOffset.Text = "0.00";
			if (-1 == selectedIndex2)
			{
				return;
			}
			if (selectedIndex == selectedIndex2)
			{
				if (this.m_listAllLevels.Count - 1 == selectedIndex)
				{
					this.m_dLevelValue = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_listAllLevels.ElementAt(selectedIndex - 1).Elevation);
				}
				else
				{
					this.m_dLevelValue = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_listAllLevels.ElementAt(selectedIndex2 + 1).Elevation - this.m_BottomLevel.Elevation);
				}
				this.m_dStairsHeight = this.m_dLevelValue;
				this.TopOffset = this.m_dLevelValue;
				this.m_dLevelValue = 0.0;
			}
			else
			{
				this.m_dStairsHeight = 0.0;
				this.m_dLevelValue = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
			}
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void cmbBottomLevel_SelectedIndexChanged(object sender, EventArgs e)
		{
			int selectedIndex = this.cmbTopLevel.SelectedIndex;
			int selectedIndex2 = this.cmbBottomLevel.SelectedIndex;
			this.m_BottomLevel = this.m_listAllLevels.ElementAt(selectedIndex2);
			this.hyTbBottomOffset.Text = "0.00";
			this.m_dBottomElevation = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_BottomLevel.Elevation);
			if (selectedIndex == selectedIndex2)
			{
				if (this.m_listAllLevels.Count - 1 == selectedIndex)
				{
					this.m_dLevelValue = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_listAllLevels.ElementAt(selectedIndex - 1).Elevation);
				}
				else
				{
					this.m_dLevelValue = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_listAllLevels.ElementAt(selectedIndex2 + 1).Elevation - this.m_BottomLevel.Elevation);
				}
				this.m_dStairsHeight = this.m_dLevelValue;
				this.TopOffset = this.m_dLevelValue;
				this.m_dLevelValue = 0.0;
			}
			else
			{
				this.m_dStairsHeight = 0.0;
				this.m_dLevelValue = YJKRevitStairs.StairsModel.CommonUnit.Common.FeetToMM(this.m_TopLevel.Elevation - this.m_BottomLevel.Elevation);
			}
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_TreadHeight);
			this.m_MainPreviewer.Refresh();
		}

		private void cmbBottomLevel_Validating(object sender, CancelEventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶部低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
		}

		private void cmbTopLevel_Validating(object sender, CancelEventArgs e)
		{
			if (this.cmbBottomLevel.SelectedIndex > this.cmbTopLevel.SelectedIndex)
			{
				MessageBox.Show("楼梯顶部低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
		}

		private void hyTbTopOffset_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTopOffset.Text)
			{
				return;
			}
			this.hyTbTopOffset.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbTopOffset.Text, 0.0).ToString("f2");
			if (this.m_TopLevel.Id == this.m_BottomLevel.Id && this.TopOffset <= this.BottomOffset)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbTopOffset.Focus();
				return;
			}
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTopOffset.Text, ValidatingType.None, ref num))
			{
				MessageBox.Show("楼梯顶高参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
		}

		private void hyTbBottomOffset_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBottomOffset.Text)
			{
				return;
			}
			this.hyTbBottomOffset.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbBottomOffset.Text, 0.0).ToString("f2");
			if (this.m_TopLevel.Id == this.m_BottomLevel.Id && this.TopOffset <= this.BottomOffset)
			{
				MessageBox.Show("楼梯顶高低于楼梯底部.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.hyTbBottomOffset.Focus();
				return;
			}
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbBottomOffset.Text, ValidatingType.None, ref num))
			{
				MessageBox.Show("起始高度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
		}

		private void hyTbStairsWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbStairsWidth.Text)
			{
				return;
			}
			this.hyTbStairsWidth.Text = Convert.ToDouble(this.hyTbStairsWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbStairsWidth.Text, ValidatingType.GreaterThanZero, ref num) || !ValueValidatingKit.ValidatingDouble(this.hyTbWellWidth.Text, ValidatingType.GreaterThanAndEqualZero, ref num))
			{
				MessageBox.Show("梯间宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.StairsWidth = this.m_listStairsData.ElementAt(0);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbStairsLength_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbStairsLength.Text)
			{
				return;
			}
			if (Convert.ToDouble(this.hyTbStairsLength.Text) - this.LandingWidth * 2.0 < 100.0)
			{
				this.StairsLength = this.StairsLength;
				return;
			}
			this.hyTbStairsLength.Text = Convert.ToDouble(this.hyTbStairsLength.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbStairsLength.Text, ValidatingType.GreaterThanZero, ref num) || !ValueValidatingKit.ValidatingDouble(this.hyTbWellWidth.Text, ValidatingType.GreaterThanAndEqualZero, ref num))
			{
				MessageBox.Show("梯间长度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.StairsWidth = this.m_listStairsData.ElementAt(0);
				this.StairsLength = this.m_listStairsData.ElementAt(1);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbWellWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbWellWidth.Text)
			{
				return;
			}
			this.hyTbWellWidth.Text = Convert.ToDouble(this.hyTbWellWidth.Text).ToString("f2");
			if (this.WellWidth >= this.StairsWidth)
			{
				MessageBox.Show("梯井宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.WellWidth = this.m_listStairsData.ElementAt(7);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbTreadHeight_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTreadHeight.Text)
			{
				return;
			}
			this.hyTbTreadHeight.Text = Convert.ToDouble(this.hyTbTreadHeight.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTreadHeight.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("踏步高度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TreadHeight = this.m_listStairsData.ElementAt(2);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbTreadDepth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbTreadDepth.Text)
			{
				return;
			}
			this.hyTbTreadDepth.Text = Convert.ToDouble(this.hyTbTreadDepth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbTreadDepth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("踏步宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.TreadDepth = this.m_listStairsData.ElementAt(3);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbBeamWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBeamWidth.Text)
			{
				return;
			}
			this.hyTbBeamWidth.Text = Convert.ToDouble(this.hyTbBeamWidth.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbBeamWidth.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯梁宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.BeamWidth = this.m_listStairsData.ElementAt(4);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbBeamHeight_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbBeamHeight.Text)
			{
				return;
			}
			this.hyTbBeamHeight.Text = Convert.ToDouble(this.hyTbBeamHeight.Text).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbBeamHeight.Text, ValidatingType.GreaterThanZero, ref num))
			{
				MessageBox.Show("梯梁高度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.BeamHeight = this.m_listStairsData.ElementAt(5);
				return;
			}
			this.UpdateStairsData();
		}

		private void hyTbRotateAngle_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbRotateAngle.Text)
			{
				return;
			}
			this.hyTbRotateAngle.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(this.hyTbRotateAngle.Text, 0.0).ToString("f2");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbRotateAngle.Text, ValidatingType.Minus2PITo2PI, ref num))
			{
				MessageBox.Show("旋转角度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.RotateAngle = this.m_listStairsData.ElementAt(6);
				return;
			}
			this.UpdateStairsData();
		}

		private bool IsValidLandingWidth(double dStairsLength, double dLandWidth)
		{
			return dStairsLength > 2.0 * dLandWidth;
		}

		private void hyTbLandingWidth_Validating(object sender, CancelEventArgs e)
		{
			if ("" == this.hyTbLandingWidth.Text)
			{
				return;
			}
			this.hyTbLandingWidth.Text = Convert.ToDouble(this.hyTbLandingWidth.Text).ToString("f0");
			double num = 0.0;
			if (!ValueValidatingKit.ValidatingDouble(this.hyTbLandingWidth.Text, ValidatingType.GreaterThanAndEqualZero, ref num) || !this.IsValidLandingWidth(this.StairsLength, this.LandingWidth))
			{
				MessageBox.Show("平台宽度参数不正确.", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				this.LandingWidth = this.m_listStairsData.ElementAt(8);
				return;
			}
			this.UpdateStairsData();
		}

		private void btnStairsWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = MultiRunStairsForm.MeasureType.MT_StairsWidth;
			this.hyTbStairsWidth.Focus();
		}

		private void btnStairsLength_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = MultiRunStairsForm.MeasureType.MT_StairsLength;
			this.hyTbStairsLength.Focus();
		}

		private void btnRotateAngle_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = MultiRunStairsForm.MeasureType.MT_Angle;
		}

		private void btnChangeInsertPoint_Click(object sender, EventArgs e)
		{
			int num = this.m_BasePointIndex + 1;
			this.m_BasePointIndex = num % 4;
			this.m_MainPreviewer.Refresh();
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (StairsFormManager.IsInvalidFormInput(this))
			{
				return;
			}
			this.m_MeasureType = MultiRunStairsForm.MeasureType.MT_None;
			string message = "";
			if (!this.ValidatingDataParam(ref message))
			{
				DialogResult dialogResult = YJKMessageBox.Show(message, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
				if (DialogResult.Cancel == dialogResult)
				{
					return;
				}
				if (DialogResult.OK == dialogResult)
				{
					base.DialogResult = DialogResult.OK;
					base.Close();
				}
			}
			base.DialogResult = DialogResult.OK;
		}

		private void nud1RunNum_ValueChanged(object sender, EventArgs e)
		{
			MultiRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nud1RunNum);
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_AddOne)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_Run1TreadCountAdd);
			}
			else if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_SubtractOne)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_Run1TreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nud2RunNum_ValueChanged(object sender, EventArgs e)
		{
			MultiRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nud2RunNum);
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_AddOne)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_Run2TreadCountAdd);
			}
			else if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_SubtractOne)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_Run2TreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nud3RunNum_ValueChanged(object sender, EventArgs e)
		{
			MultiRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nud3RunNum);
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_AddOne)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_Run3TreadCountAdd);
			}
			else if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_SubtractOne)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_Run3TreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nud4RunNum_ValueChanged(object sender, EventArgs e)
		{
			MultiRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nud4RunNum);
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_AddOne)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_Run4TreadCountAdd);
			}
			else if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_SubtractOne)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_Run4TreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void nudTreadCount_ValueChanged(object sender, EventArgs e)
		{
			MultiRunStairsForm.ValveChangeType valveChangeType = this.isAddNumericUpDown(this.nudTreadCount);
			if (valveChangeType == MultiRunStairsForm.ValveChangeType.VCT_None)
			{
				return;
			}
			if (MultiRunStairsForm.ValveChangeType.VCT_AddOne == valveChangeType)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_TreadCountAdd);
			}
			else if (MultiRunStairsForm.ValveChangeType.VCT_SubtractOne == valveChangeType)
			{
				this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_TreadCountSub);
			}
			this.m_MainPreviewer.Refresh();
		}

		private void hycmbRunNum_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.RunNum = this.RunNum;
			this.ParametersCalculate(MultiRunStairsForm.ParametersChangeType.PCT_RunNum);
			this.m_MainPreviewer.Refresh();
		}

		public const double _epsDouble = 1E-09;

		private int m_nMaxTread = FormParamManager.GetRunMaxTread();

		private int m_nMinTread = FormParamManager.GetRunMinTread();

		private ExternalCommandData m_Revit;

		private Previewer m_MainPreviewer;

		private MultiRunStairsKit m_ProjectionDrawingKit;

		private ComponentTypeManager m_ComponentTypeManager;

		private StairArchStd m_StairArchStd;

		private List<Level> m_listAllLevels;

		private MultiRunStairsForm.MeasureType m_MeasureType;

		private XYZ m_BasePoint;

		private int m_BasePointIndex;

		private bool m_Calculating;

		private bool m_bInitialize = true;

		private double m_dTreadThickness;

		private double m_dBottomElevation;

		private double m_dLevelValue;

		private Level m_TopLevel;

		private Level m_BottomLevel;

		private List<double> m_listStairsData;

		private double m_dStairsHeight;

		private int m_nRiserSubTread = 3;

		public enum MeasureType
		{
			MT_None,
			MT_StairsWidth,
			MT_StairsLength,
			MT_Angle
		}

		public enum ValveChangeType
		{
			VCT_None,
			VCT_AddOne,
			VCT_SubtractOne,
			VCT_ValveChanged
		}

		private enum ParametersChangeType
		{
			PCT_TreadHeight,
			PCT_RunNum,
			PCT_TreadCount,
			PCT_Run1TreadCount,
			PCT_Run2TreadCount,
			PCT_Run3TreadCount,
			PCT_Run4TreadCount,
			PCT_TreadCountAdd,
			PCT_Run1TreadCountAdd,
			PCT_Run2TreadCountAdd,
			PCT_Run3TreadCountAdd,
			PCT_Run4TreadCountAdd,
			PCT_TreadCountSub,
			PCT_Run1TreadCountSub,
			PCT_Run2TreadCountSub,
			PCT_Run3TreadCountSub,
			PCT_Run4TreadCountSub,
			PCT_StairsWidth,
			PCT_StairsLength,
			PCT_LandingWidth,
			PCT_TreadDepth
		}
	}
}
